package com.example.dto;

import com.example.model.dto.BaseDTO;
import com.example.mybatis.entity.BaseEntity;
import com.example.utils.DateUtils;
import com.example.validator.group.AddGroup;
import com.example.validator.group.DefaultGroup;
import com.example.validator.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 系统用户DTO
 */
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(description = "系统用户")
public class SysUserDTO extends BaseDTO implements Serializable {
    private static final long serialVersionUID = 1L;

//    @Schema(description = "ID", accessMode = Schema.AccessMode.READ_ONLY) // 或者完全省略此字段
    @Null(message="{id.null}", groups = AddGroup.class)
    @NotNull(message="{id.require}", groups = UpdateGroup.class)
    @Schema(description = "id", required = false, example = "")
    private Long id;

    private Long tentantId;
    private Long storeId;
    private Integer isSuperTenant;
    private Integer isHeadStore;
    private String storeName;
    private String tenantName;

    @Schema(description = "用户名")
    @NotBlank(message="{sysuser.username.require}", groups = DefaultGroup.class)
    private String username;

    @Schema(description = "原密码", required = true)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String oldPassword;

    @Schema(description = "密码", required = true)
    @NotBlank(message="密码不能为空", groups = AddGroup.class)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    @Schema(description = "确认密码", required = true)
    @NotBlank(message="确认密码不能为空", groups = AddGroup.class)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String confirmPassword;

    @Schema(description = "姓名")
    private String realName;

    @Schema(description = "头像")
    private String headUrl;

    @Schema(description = "性别   0：男   1：女    2：保密", required = false, example = "0")
    @Range(min=0, max=2, message = "{sysuser.gender.range}", groups = DefaultGroup.class)
    private Integer gender;

    @Schema(description = "邮箱")
    @Email(message="{sysuser.email.error}", groups = DefaultGroup.class)
    private String email;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "部门ID")
//    @NotNull(message="{sysuser.deptId.require}", groups = DefaultGroup.class)
    private Long deptId;

    @Schema(description = "部门名称")
    private String deptName;

    @Schema(description = "角色id")
    private List<Long> roleIdList;

    @Schema(description = "岗位id")
    private List<Long> postIdList;

    @Schema(description = "状态  0：停用   1：正常", required = false, example = "1")
    @Range(min=0, max=1, message = "{sysuser.status.range}", groups = DefaultGroup.class)
    private Integer status;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "删除标识  0：未删除    1：删除", required = false, example = "0")
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private Integer delFlag;
} 